/**
 * @description 下拉框
 * @date 2024.9.10
 * @author wz
 * @midify 2025.5.15
 * @editor wz
 */
import { _decorator, Color, Label, Node } from "cc";
import CDropDownBase from "./CDropDownBase";
const { ccclass, property } = _decorator;

/**
 * 可继承实现自定义下拉菜单
 */
@ccclass('CDropDown')
export default class CDropDown extends CDropDownBase {

    @property(Label)
    showLabel: Label = null;

    @property({ type: Color, tooltip: '未选中的字颜色', displayName: '未选中的字颜色' })
    norColor: Color = new Color(162, 183, 199);

    @property({ type: Color, tooltip: '选中的字颜色', displayName: '选中的字颜色' })
    selColor: Color = new Color(255, 255, 255);


    setDrop(index: number, option: string) {
        this.showLabel.string = option;
    }
    setItem(item: Node, isSel: boolean, index: number, option: string) {
        let label = item.getChildByName('label').getComponent(Label)
        label.string = option;
        label.color = isSel ? this.selColor : this.norColor;
        label.outlineColor = isSel ? this.selColor : this.norColor;
        item.getChildByName('choose').active = isSel;
    }
}
